package com.serviceprovider.business.module.admin.license.model;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.admin.acl.utility.AbstractEntity;

/**
 * Represents Site License. Some licenses can be meant for all the different users. While some can be only for a
 * specific user type / role. e.g. "Service Provider" only or "Affiliate" only or "Payees" only. This can be simply
 * controlled by one single flag... "isLicenseAgreed"
 */
public class License extends AbstractEntity {
    private static final long serialVersionUID = 1L;
    private boolean           active;
    private byte[]            attachments;
    private String            comments;
    private String            filename;
    private Integer           id;
    private String            name;
    private String            text;

    @Override
    public boolean equals(Object obj) {
        if ((obj == null) ||!(obj instanceof License)) {
            return false;
        }

        License b  = (License) obj;
        boolean eq = ((id == null) && (b.id == null)) || ((id != null) && id.equals(b.id));

        if (!eq) {
            return false;
        }

        eq = ((name == null) && (b.name == null)) || ((name != null) && name.equals(b.name));

        if (!eq) {
            return false;
        }

        eq = ((text == null) && (b.text == null)) || ((text != null) && text.equals(b.text));

        if (!eq) {
            return false;
        }

        eq = ((comments == null) && (b.comments == null)) || ((comments != null) && comments.equals(b.comments));

        if (!eq) {
            return false;
        }

        eq = ((filename == null) && (b.filename == null)) || ((filename != null) && filename.equals(b.filename));

        if (!eq) {
            return false;
        }

        eq = (active == b.active);

        if (!eq) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int prime  = 31;
        int result = 1;

        result = prime * result + ((id == null)
                                   ? 0
                                   : id.hashCode());
        result = prime * result + ((name == null)
                                   ? 0
                                   : name.hashCode());
        result = prime * result + ((text == null)
                                   ? 0
                                   : text.hashCode());
        result = prime * result + ((comments == null)
                                   ? 0
                                   : comments.hashCode());
        result = prime * result + ((active == false)
                                   ? 0
                                   : 1);
        result = prime * result + ((filename == null)
                                   ? 0
                                   : filename.hashCode());

        return result;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public byte[] getAttachments() {
        return attachments;
    }

    public void setAttachments(byte[] attachments) {
        this.attachments = attachments;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
}



